﻿using LaoLuo.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;

namespace LaoLuo.Common.Test
{
    
    
    /// <summary>
    ///This is a test class for FileExtensionsTest and is intended
    ///to contain all FileExtensionsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class FileExtensionsTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetFileExtension
        ///</summary>
        [TestMethod()]
        public void GetFileExtensionTest()
        {
            string file = "aaaa.123...txt";
            string expected = ".txt";
            string actual;
            actual = FileExtensions.GetFileExtension(file);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetFilesByExtension
        ///</summary>
        [TestMethod()]
        public void GetFilesByExtensionTest()
        {
            var ext = new List<string>() { ".H1K", ".zip" };
            AssertHelper.AreEqual(@"C:\Windows\Help\Windows\en-US".GetFilesByExtension(ext), @"C:\Windows\Help\Windows\en-US\Windows_AssetId.H1K", @"C:\Windows\Help\Windows\en-US\Windows_BestBet.H1K", @"C:\Windows\Help\Windows\en-US\Windows_LinkTerm.H1K", @"C:\Windows\Help\Windows\en-US\Windows_SubjectTerm.H1K");
        }

        /// <summary>
        ///A test for GetFilename
        ///</summary>
        [TestMethod()]
        public void GetFileNameWithoutExtensionTest()
        {
            Assert.AreEqual("[SC-OL][Gintama]001-002", @"D:\downloads\银魂第一季01-201话\[SC-OL][Gintama]001-002.rmvb".GetFileNameWithoutExtension());
        }

        /// <summary>
        ///A test for WhereExtensionIn
        ///</summary>
        [TestMethod()]
        public void WhereExtensionInTest()
        {
            AssertHelper.AreEqual(@"C:\Windows\Help\Windows\en-US".GetFilesByExtension(".h1k", ".h1c").WhereExtensionIn(".h1c"), @"C:\Windows\Help\Windows\en-US\Windows.h1c");
        }

        /// <summary>
        ///GetFilesWithoutPath 的测试
        ///</summary>
        [TestMethod()]
        public void GetFilesWithoutPathTest()
        {
            AssertHelper.AreEqual(@"C:\Windows\Help\Windows\en-US".GetFilesWithoutPath(), "Windows.h1c",
"Windows_AssetId.H1K",
"Windows_BestBet.H1K",
"Windows_LinkTerm.H1K",
"Windows_SubjectTerm.H1K");
        }
    }
}
